-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Update Angular to support TS 3.9 #36989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
708e1e3
build: pin @microsoft/api-extractor to 7.7.11
alan-agius4 96c5574
fix(language-service): use empty statement as parent of type node
6a66575
test(language-service): external template update should not invalidat…
67a4e51
build: prepare for TypeScript 3.9
alan-agius4 e5ca0be
refactor(ngcc): simplify the `detectKnownDeclaration()` signature
petebacondarwin 605f6ae
refactor(compiler-cli): simplify and clarify `TypeScriptReflectionHos…
petebacondarwin dfd69b6
refactor(compiler-cli): delegate `hasBaseClass()` to `getBaseClassExp…
petebacondarwin 1a6a71f
refactor(ngcc): remove unused import
petebacondarwin 5949f3a
refactor(ngcc): ensure unlocker process works in mock file-systems
petebacondarwin e97dfd7
fix(ngcc): ensure reflection hosts can handle TS 3.9 IIFE wrapped cla…
petebacondarwin 8657a24
fix(ngcc): ensure rendering formatters work with IIFE wrapped classes
petebacondarwin 233ef52
test(ngcc): move specs to correct describe block
petebacondarwin 50c1659
test(compiler-cli): hande TS 3.9 format in emisson tests
petebacondarwin f729a2c
test(ngcc): reformat some subject code for tests
petebacondarwin c7f7882
refactor(ngcc): rename `ReexportStatement` to `WildcardReexportStatem…
petebacondarwin 57edd6b
docs(ngcc): tidy up typos etc in comments
petebacondarwin d202276
fix(ngcc): `viaModule` should be `null` for local imports
petebacondarwin b086ca9
fix(ngcc): support `defineProperty()` re-exports in CommonJS and UMD
petebacondarwin f6c0559
test(docs-infra): update payload sizes after TS 3.9 update
petebacondarwin 7b455b1
fix(compiler-cli): compute the correct target output for `$localize` …
petebacondarwin 8391ab8
test: update payload sizes after TS 3.9 update
alan-agius4 ade3796
test: enable importHelpers for UMD builds
alan-agius4 d0bf4b3
test: disable `cli-hello-world-lazy-rollup` from ivy tests
alan-agius4 5125158
refactor: `EventEmitter` to retain behaviour of pre TypeScript 3.9
alan-agius4 cabdb74
test: update language service module resolution cache
alan-agius4 d53f40e
build(docs-infra): correctly handle "pseudo" classes
petebacondarwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
20 changes: 20 additions & 0 deletions
20
aio/tools/transforms/angular-api-package/mocks/methodParameters.ts
This file contains hidden or 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,20 @@ | ||
export class TestClass { | ||
method1( | ||
/** description of param1 */ param1: number, | ||
/** description of param2 */ param2?: string, | ||
/** description of param3 */ param3: object = {}, | ||
/** description of param4 */ param4 = 'default string', | ||
) { | ||
/// | ||
} | ||
|
||
/** | ||
* Some description of method 2 | ||
* @param param5 description of param5 | ||
* @param param6 description of param6 | ||
* @param param7 description of param7 | ||
*/ | ||
method2(param5: string, param6: number, param7 = 42) { | ||
// | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
aio/tools/transforms/angular-api-package/processors/mergeParameterInfo.js
This file contains hidden or 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,31 @@ | ||
/** | ||
* @dgProcessor | ||
* | ||
* @description | ||
* Merge the description from `@param` tags into the parameter docs | ||
* extracted from the TypeScript | ||
* | ||
* This is actually an override of the processor provided by the `typescript` dgeni package. | ||
* The original does not set the `defaultValue`. | ||
*/ | ||
module.exports = function mergeParameterInfo() { | ||
return { | ||
$runAfter: ['readTypeScriptModules', 'tags-extracted'], | ||
$runBefore: ['extra-docs-added'], | ||
$process(docs) { | ||
docs.forEach((doc) => { | ||
if (doc.docType === 'parameter') { | ||
// The `params` property comes from parsing the `@param` jsdoc tags on the container doc | ||
const paramTag = | ||
doc.container.params && doc.container.params.find(param => param.name === doc.name); | ||
if (paramTag && paramTag.description) { | ||
doc.description = paramTag.description; | ||
if (doc.defaultValue === undefined) { | ||
doc.defaultValue = paramTag.defaultValue; | ||
} | ||
} | ||
} | ||
}); | ||
}, | ||
}; | ||
}; |
48 changes: 48 additions & 0 deletions
48
aio/tools/transforms/angular-api-package/processors/mergeParameterInfo.spec.js
This file contains hidden or 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,48 @@ | ||
const Dgeni = require('dgeni'); | ||
const path = require('canonical-path'); | ||
const testPackage = require('../../helpers/test-package'); | ||
|
||
describe('mergeParameterInfo', () => { | ||
let injector; | ||
let tsProcessor; | ||
let mergeParameterInfoProcessor; | ||
let parseTagsProcessor; | ||
let extractTagsProcessor; | ||
|
||
beforeEach(() => { | ||
const dgeni = new Dgeni([testPackage('angular-api-package')]); | ||
injector = dgeni.configureInjector(); | ||
|
||
tsProcessor = injector.get('readTypeScriptModules'); | ||
parseTagsProcessor = injector.get('parseTagsProcessor'); | ||
extractTagsProcessor = injector.get('extractTagsProcessor'); | ||
mergeParameterInfoProcessor = injector.get('mergeParameterInfo'); | ||
tsProcessor.basePath = path.resolve(__dirname, '../mocks'); | ||
tsProcessor.sourceFiles = ['methodParameters.ts']; | ||
}); | ||
|
||
it('should merge the param tags into the parameter docs', () => { | ||
const docsArray = []; | ||
|
||
tsProcessor.$process(docsArray); | ||
parseTagsProcessor.$process(docsArray); | ||
extractTagsProcessor.$process(docsArray); | ||
mergeParameterInfoProcessor.$process(docsArray); | ||
|
||
const param5 = docsArray.find(doc => doc.name === 'param5' && doc.container.name === 'method2'); | ||
expect(param5.id).toEqual('methodParameters/TestClass.method2()~param5'); | ||
expect(param5.description).toEqual('description of param5'); | ||
expect(param5.type).toEqual('string'); | ||
|
||
const param6 = docsArray.find(doc => doc.name === 'param6' && doc.container.name === 'method2'); | ||
expect(param6.id).toEqual('methodParameters/TestClass.method2()~param6'); | ||
expect(param6.description).toEqual('description of param6'); | ||
expect(param6.type).toEqual('number'); | ||
|
||
const param7 = docsArray.find(doc => doc.name === 'param7' && doc.container.name === 'method2'); | ||
expect(param7.id).toEqual('methodParameters/TestClass.method2()~param7'); | ||
expect(param7.description).toEqual('description of param7'); | ||
expect(param7.type).toEqual('number'); | ||
expect(param7.defaultValue).toEqual('42'); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
aio/tools/transforms/angular-api-package/processors/processPseudoClasses.js
This file contains hidden or 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,27 @@ | ||
module.exports = function processPseudoClasses(tsHost) { | ||
return { | ||
$runAfter: ['readTypeScriptModules'], | ||
$runBefore: ['parsing-tags'], | ||
$process(docs) { | ||
docs.forEach(doc => { | ||
if (doc.docType === 'interface' && doc.additionalDeclarations && | ||
doc.additionalDeclarations.length > 0) { | ||
doc.docType = 'class'; | ||
const additionalContent = tsHost.getContent(doc.additionalDeclarations[0]); | ||
if (!doc.content || doc.content === '@publicApi' && additionalContent) { | ||
doc.content = additionalContent; | ||
} | ||
doc.members = doc.members && doc.members.filter(m => { | ||
if (m.isNewMember) { | ||
doc.constructorDoc = m; | ||
doc.constructorDoc.name = 'constructor'; | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}; | ||
}; |
97 changes: 97 additions & 0 deletions
97
aio/tools/transforms/angular-api-package/processors/processPseudoClasses.spec.js
This file contains hidden or 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,97 @@ | ||
const testPackage = require('../../helpers/test-package'); | ||
const processorFactory = require('./processPseudoClasses'); | ||
const Dgeni = require('dgeni'); | ||
|
||
describe('processPseudoClasses processor', () => { | ||
it('should be available on the injector', () => { | ||
const dgeni = new Dgeni([testPackage('angular-api-package')]); | ||
const injector = dgeni.configureInjector(); | ||
const processor = injector.get('processPseudoClasses'); | ||
expect(processor.$process).toBeDefined(); | ||
expect(processor.$runAfter).toEqual(['readTypeScriptModules']); | ||
expect(processor.$runBefore).toEqual(['parsing-tags']); | ||
}); | ||
|
||
it('should convert "interface+const" docs to "class" docs', () => { | ||
const processor = processorFactory(jasmine.createSpyObj(['getContent'])); | ||
const docs = [ | ||
{docType: 'module', id: 'a'}, | ||
{docType: 'class', id: 'b'}, | ||
{docType: 'interface', id: 'c'}, | ||
{docType: 'interface', id: 'd', additionalDeclarations: []}, | ||
{docType: 'interface', id: 'e', additionalDeclarations: [{}]}, | ||
{docType: 'const', id: 'f'}, | ||
{docType: 'const', id: 'g', additionalDeclarations: []}, | ||
{docType: 'const', id: 'h', additionalDeclarations: [{}]}, | ||
]; | ||
processor.$process(docs); | ||
expect(docs).toEqual([ | ||
jasmine.objectContaining({docType: 'module', id: 'a'}), | ||
jasmine.objectContaining({docType: 'class', id: 'b'}), | ||
jasmine.objectContaining({docType: 'interface', id: 'c'}), | ||
jasmine.objectContaining({docType: 'interface', id: 'd'}), | ||
|
||
// This is the only one that changes | ||
jasmine.objectContaining({docType: 'class', id: 'e'}), | ||
|
||
jasmine.objectContaining({docType: 'const', id: 'f'}), | ||
jasmine.objectContaining({docType: 'const', id: 'g'}), | ||
jasmine.objectContaining({docType: 'const', id: 'h'}), | ||
]); | ||
}); | ||
|
||
it('should grab the content from the first additional declaration if there is no "real" content already', | ||
() => { | ||
const getContent = jasmine.createSpy('getContent').and.returnValue('additional content'); | ||
const additionalDeclaration1 = {}; | ||
const additionalDeclaration2 = {}; | ||
const additionalDeclaration3 = {}; | ||
const processor = processorFactory({getContent}); | ||
const docs = [ | ||
{ | ||
docType: 'interface', | ||
id: 'a', | ||
content: 'original content', | ||
additionalDeclarations: [additionalDeclaration1] | ||
}, | ||
{ | ||
docType: 'interface', | ||
id: 'b', | ||
content: '@publicApi', // this does not count as "real" content | ||
additionalDeclarations: [additionalDeclaration2] | ||
}, | ||
{docType: 'interface', id: 'c', additionalDeclarations: [additionalDeclaration3]}, | ||
]; | ||
processor.$process(docs); | ||
expect(docs[0].content).toEqual('original content'); | ||
expect(docs[1].content).toEqual('additional content'); | ||
expect(docs[2].content).toEqual('additional content'); | ||
expect(getContent).toHaveBeenCalledWith(additionalDeclaration1); | ||
expect(getContent).toHaveBeenCalledWith(additionalDeclaration2); | ||
expect(getContent).toHaveBeenCalledWith(additionalDeclaration3); | ||
}); | ||
|
||
it('should extract any __new member from the interface members', () => { | ||
const getContent = jasmine.createSpy('getContent').and.returnValue('additional content'); | ||
const processor = processorFactory({getContent}); | ||
const docs = [ | ||
{docType: 'interface', id: 'a', additionalDeclarations: [{}]}, | ||
{docType: 'interface', id: 'b', additionalDeclarations: [{}], members: []}, | ||
{docType: 'interface', id: 'c', additionalDeclarations: [{}], members: [{name: 'member1'}]}, | ||
{ | ||
docType: 'interface', | ||
id: 'd', | ||
additionalDeclarations: [{}], | ||
members: [{name: 'member1', isNewMember: true}] | ||
}, | ||
]; | ||
processor.$process(docs); | ||
|
||
expect(docs[0].members).toEqual(undefined); | ||
expect(docs[1].members).toEqual([]); | ||
expect(docs[2].members).toEqual([{name: 'member1'}]); | ||
|
||
expect(docs[3].members).toEqual([]); | ||
expect(docs[3].constructorDoc).toEqual({name: 'constructor', isNewMember: true}); | ||
}); | ||
}); |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the diffs documented in the commit message don't look right. I think we should land this PR as is and file JIRAs for the individual diffs and investigate them one by one before the 10.0.0 is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JIRA created: FW-2166