Skip to content

Commit

Permalink
fix: typescript createProgram doesn't support incremental mode (#5346)
Browse files Browse the repository at this point in the history
* fix: typescript createProgram doesn't support incremental mode

* test: added test for PR #5346

Co-authored-by: Jasper De Moor <jasperdemoor@gmail.com>
  • Loading branch information
paeolo and DeMoorJasper committed Nov 14, 2020
1 parent 6100114 commit 837d1fb
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const add = (a: number, b: number) => a + b;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const add: (a: number, b: number) => number;

//# sourceMappingURL=index.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './add';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "ts-composite",
"private": true,
"main": "dist/main.js",
"types": "dist/index.d.ts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
},
"files": [
"index.ts",
"add.ts"
],
"references": []
}
Empty file.
18 changes: 18 additions & 0 deletions packages/core/integration-tests/test/ts-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,22 @@ describe('typescript types', function() {

assert(/import\s*{\s*B\s*}\s*from\s*"b";/.test(dist));
});

it('should generate a typescript declaration file even when composite is true', async function() {
await bundle(
path.join(__dirname, '/integration/ts-types/composite/index.ts'),
);

let dist = (
await outputFS.readFile(
path.join(__dirname, '/integration/ts-types/composite/dist/index.d.ts'),
'utf8',
)
).replace(/\r\n/g, '\n');
let expected = await inputFS.readFile(
path.join(__dirname, '/integration/ts-types/composite/expected.d.ts'),
'utf8',
);
assert.equal(dist, expected);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export default (new Transformer({
emitDeclarationOnly: true,
outFile: 'index.d.ts',
moduleResolution: ts.ModuleResolutionKind.NodeJs,
// createProgram doesn't support incremental mode
composite: false,
};

let host = new CompilerHost(options.inputFS, ts, logger);
Expand Down

0 comments on commit 837d1fb

Please sign in to comment.