Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@mrgrain/jsii-extend-interface
Advanced tools
A projen component to easily extend and adapt existing jsii interfaces
A projen component to easily extend and adapt existing jsii interfaces.
Jsii doesn't support TypeScript Utility Types like Partial
or Omit
, making it difficult to extend existing interfaces.
This component works around that limitation by generating a brand new interface based on the jsii specification of the extended interface and its parent interfaces.
From jsii's perspective, these interfaces are completely new types. From a maintainer's perspective, they require the same minimal effort as utility types do. Everybody wins!
Install with:
npm install --save-dev @mrgrain/jsii-extend-interface
Use the jsii FQN to extend an existing interface.
Use omit
to remove any properties you are not interested in.
new JsiiInterface(project, {
name: 'MyProjectOptions',
extends: 'projen.typescript.TypeScriptProjectOptions',
omit: ['sampleCode', 'projenrcTs', 'projenrcTsOptions']
});
New properties can be added with a @jsii/spec
definition.
Complex types can be used and will be imported using their FQN.
Any existing properties of the same name will be replaced.
new JsiiInterface(project, {
name: 'MyProjectOptions',
extends: 'projen.typescript.TypeScriptProjectOptions',
props:{
booleanSetting: {
type: { primitive: jsii.PrimitiveType.Boolean }
},
complexSetting: {
type: { fqn: "my_project.SomeEnum" }
}
}
});
Existing properties can be updated.
The provided partial @jsii/spec
definition will be merged (non-recursively) with the existing spec.
new JsiiInterface(project, {
name: 'MyProjectOptions',
extends: 'projen.typescript.TypeScriptProjectOptions',
updateProps:{
typescriptVersion: {
optional: false,
},
sampleCode: {
docs: {
summary: 'New summary',
default: 'false',
}
}
}
});
Extending an existing interface is optional. The component can be used to generated interfaces from scratch.
new JsiiInterface(project, {
name: 'MyProjectOptions',
props:{
complexSetting: {
type: { fqn: "my_project.SomeEnum" }
}
}
});
The default configuration makes assumptions about the new interface that are usually okay.
For more complex scenarios fqn
, filePath
and importLocations
can be used to influence the rendered output.
new JsiiInterface(project, {
name: 'MyProjectOptions',
extends: 'projen.typescript.TypeScriptProjectOptions',
fqn: 'my_project.nested.location.MyProjectOptions',
filePath: 'src/nested/my-project-options.ts',
importLocations: {
'my_project': '../enums'
},
props:{
complexSetting: {
type: { fqn: "my_project.SomeEnum" }
}
}
});
FAQs
A projen component to easily extend and adapt existing jsii interfaces
The npm package @mrgrain/jsii-extend-interface receives a total of 0 weekly downloads. As such, @mrgrain/jsii-extend-interface popularity was classified as not popular.
We found that @mrgrain/jsii-extend-interface demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.