Skip to content

Commit

Permalink
Add support for js index file - #219 (#251)
Browse files Browse the repository at this point in the history
Add itest to cover use of JS files
  • Loading branch information
mrseanryan authored Dec 10, 2022
1 parent 0b792e7 commit 6c21a4b
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/with-js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
14 changes: 14 additions & 0 deletions example/with-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions example/with-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "with-js",
"version": "0.0.0",
"description": "Example used by integration tests (ispec) - with-js",
"main": "src/index.js",
"scripts": {
"build": "tsc --allowJs",
"test": "tsc --allowJs && ../../bin/ts-unused-exports tsconfig.json"
},
"license": "MIT",
"devDependencies": {
"typescript": "^4.7.4"
}
}
2 changes: 2 additions & 0 deletions example/with-js/src/Component/Component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export function Component() {
}
5 changes: 5 additions & 0 deletions example/with-js/src/Game/Entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Component } from '../Component/Component.js'

export class Entity
{
}
2 changes: 2 additions & 0 deletions example/with-js/src/Game/Player.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export function Player() {
}
6 changes: 6 additions & 0 deletions example/with-js/src/comp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as React from 'react';
import { thisOneIsUsed } from './util';

const Comp = ({ a }: { a: string }) => <div>{thisOneIsUsed}{a}</div>;

console.log(Comp);
7 changes: 7 additions & 0 deletions example/with-js/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Entity } from './Game/Entity'
import { Player } from './Game/Player.js'
import { thisOneIsUsed } from "./util"

console.log(`Entity: ${Entity}`)
console.log(`Player: ${Player}`)
console.log(`thisOneIsUsed: ${thisOneIsUsed}`)
1 change: 1 addition & 0 deletions example/with-js/src/unused.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const thisOneIsNotUsed = 2;
2 changes: 2 additions & 0 deletions example/with-js/src/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const thisOneIsUsed = 1;
export const thisOneIsNotUsed = 2;
15 changes: 15 additions & 0 deletions example/with-js/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "es6",
"target": "es2019",
"noImplicitAny": false,
"alwaysStrict": true,
"removeComments": true,
"strictNullChecks": true,
"preserveConstEnums": true,
"sourceMap": true,
"outDir": "build"
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
}
4 changes: 4 additions & 0 deletions ispec/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,9 @@ pushd ../example/path-alias-and-sub-folders
run_itest
popd

pushd ../example/with-js
run_itest
popd

# Test running from another directory
./_run_from_directory_not_project.sh

0 comments on commit 6c21a4b

Please sign in to comment.