Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow opting-in to
.ts
import specifiers (#1815)
* quick impl * fix * update * add a test * add jsdoc for new option
- Loading branch information
Showing
9 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { context } from './testlib'; | ||
import * as expect from 'expect'; | ||
import { createExec } from './exec-helpers'; | ||
import { | ||
TEST_DIR, | ||
ctxTsNode, | ||
CMD_TS_NODE_WITHOUT_PROJECT_FLAG, | ||
} from './helpers'; | ||
|
||
const exec = createExec({ | ||
cwd: TEST_DIR, | ||
}); | ||
|
||
const test = context(ctxTsNode); | ||
|
||
test('Supports .ts extensions in import specifiers with typechecking, even though vanilla TS checker does not', async () => { | ||
const { err, stdout } = await exec( | ||
`${CMD_TS_NODE_WITHOUT_PROJECT_FLAG} ts-import-specifiers/index.ts` | ||
); | ||
expect(err).toBe(null); | ||
expect(stdout.trim()).toBe('{ foo: true, bar: true }'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const bar = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const foo = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { foo } from './foo.ts'; | ||
import { bar } from './bar.jsx'; | ||
console.log({ foo, bar }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"ts-node": { | ||
// Can eventually make this a stable feature. For now, `experimental` flag allows me to iterate quickly | ||
"experimentalTsImportSpecifiers": true, | ||
"experimentalResolver": true | ||
}, | ||
"compilerOptions": { | ||
"jsx": "react" | ||
} | ||
} |