Skip to content

Commit b17a6a6

Browse files
authored
allow trailing dot when applying namespace. (#2100)
* allow trailing dot when applying namespace. * add comment * fix that
1 parent 93d419f commit b17a6a6

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

scripts/components/api-changes-validator/test-resources/test-projects/without-breaks/project-with-namespace/API.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ type SomeOtherTypeUnderSubNamespace = {
1616
someProperty: SomeTypeUnderSubNamespace;
1717
};
1818

19+
class SomeClassUnderNamespace {
20+
static readonly someStaticProperty: string;
21+
}
22+
23+
type SomeTypeUnderNamespaceWithGenerics<TPropertyType> = {
24+
someGenericProperty: TPropertyType;
25+
};
26+
1927
declare namespace someSubNamespace {
2028
export {
2129
SomeTypeUnderSubNamespace,
@@ -28,7 +36,9 @@ export const functionUsingTypes2: (props: SomeTypeUnderNamespace, extraArg: stri
2836

2937
declare namespace someNamespace {
3038
export {
39+
SomeClassUnderNamespace,
3140
SomeTypeUnderNamespace,
41+
SomeTypeUnderNamespaceWithGenerics,
3242
someSubNamespace,
3343
functionUsingTypes1,
3444
functionUsingTypes2

scripts/components/api-changes-validator/test-resources/test-projects/without-breaks/project-with-namespace/src/some_namespace.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@ export const functionUsingTypes2 = (
1414
): Array<someSubNamespace.SomeTypeUnderSubNamespace> => {
1515
throw new Error();
1616
};
17+
18+
export class SomeClassUnderNamespace {
19+
static readonly someStaticProperty: string;
20+
}
21+
22+
export type SomeTypeUnderNamespaceWithGenerics<TPropertyType> = {
23+
someGenericProperty: TPropertyType;
24+
};

scripts/components/api-changes-validator/usage_statemets_renderer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ export class UsageStatementsRenderer {
6969

7070
// characters that can be found before or after symbol
7171
// this is to prevent partial matches in case one symbol's characters are subset of longer one
72-
const symbolTerminators = '[\\s\\,\\(\\)<>;]';
72+
const possibleSymbolPrefix = '[\\s\\,\\(<;]';
73+
const possibleSymbolSuffix = '[\\s\\,\\(\\)<>;\\.]';
7374
const regex = new RegExp(
74-
`(${symbolTerminators})(${symbolName})(${symbolTerminators})`,
75+
`(${possibleSymbolPrefix})(${symbolName})(${possibleSymbolSuffix})`,
7576
'g'
7677
);
7778
usageStatements = usageStatements.replaceAll(

0 commit comments

Comments
 (0)