Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Distribute Typescript type file(s, *.d.ts) to allow type-safe use from Typescript #366

Open
toasterpic opened this issue Apr 27, 2020 · 2 comments · May be fixed by #403
Open

Distribute Typescript type file(s, *.d.ts) to allow type-safe use from Typescript #366

toasterpic opened this issue Apr 27, 2020 · 2 comments · May be fixed by #403

Comments

@toasterpic
Copy link

toasterpic commented Apr 27, 2020

TS has support for generating *.d.ts for js by flags(allowJs and declarations) in version 3.7, however it fails when applied to both the distributed firepad 1.5.10 as well as the latest sources.

Version info

Firepad: 1.5.10

Test case

tsc --allowJs --declaration --emitDeclarationOnly ./node_modules/firepad/dist/firepad.js

Expected behavior

valid firepad.d.ts created next to firepad.js

Actual behavior

node_modules/firepad/dist/firepad.js:14:1 - error TS9005: Declaration emit for this file requires using private name 'Entity'. An explicit type annotation may unblock declaration emit.

14 (function (name, definition, context) {
   ~

node_modules/firepad/dist/firepad.js:14:1 - error TS9005: Declaration emit for this file requires using private name 'Firepad'. An explicit type annotation may unblock declaration emit.

14 (function (name, definition, context) {
   ~

node_modules/firepad/dist/firepad.js:14:1 - error TS9005: Declaration emit for this file requires using private name 'Headless'. An explicit type annotation may unblock declaration emit.

14 (function (name, definition, context) {
   ~

node_modules/firepad/dist/firepad.js:14:1 - error TS9005: Declaration emit for this file requires using private name 'MonacoAdapter'. An explicit type annotation may unblock declaration emit.

14 (function (name, definition, context) {
   ~

node_modules/firepad/dist/firepad.js:14:1 - error TS9005: Declaration emit for this file requires using private name 'RichTextCodeMirrorAdapter'. An explicit type annotation may unblock declaration emit.

14 (function (name, definition, context) {
   ~

node_modules/firepad/dist/firepad.js:14:1 - error TS9005: Declaration emit for this file requires using private name 'TextOperation'. An explicit type annotation may unblock declaration emit.

14 (function (name, definition, context) {
   ~


Found 6 errors.

Test case

  1. git clone https://github.com/FirebaseExtended/firepad.git
  2. tsc --init
  3. tsc --allowJs --declaration --emitDeclarationOnly -p .

Actual behavior

examples/firepad-userlist.js:1:1 - error TS9005: Declaration emit for this file requires using private name 'FirepadUserList'. An explicit type annotation may unblock declaration emit.

1 var FirepadUserList = (function() {
  ~~~

lib/monaco-adapter.js:1:1 - error TS9005: Declaration emit for this file requires using private name 'MonacoAdapter'. An explicit type annotation may unblock declaration emit.

1 'use strict';
  ~~~~~~~~~~~~


Found 2 errors.


@samtstern
Copy link
Contributor

@toasterpic thanks for the suggestion and the detailed information. Firepad is a pretty old library so it doesn't surprise me that it needs some work to be TS-ready. If you or someone else wants to send a PR to add d.ts files (or just fix the errors above) I would be happy to review it.

@0xTheProDev
Copy link
Contributor

@toasterpic If your usecase concerns with Monaco Editor, I can offer you to use @hackerrank/firepad for the time being.
It's complete rewrite of the library in TS with modern build system powered by Webpack/ESM, but I am yet to integrate Ace and CodeMirror to and waiting for that to get completed before pulling it upstream.

@MasterOdin MasterOdin linked a pull request Sep 4, 2021 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants