Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 18:00
    typescript-bot closed #33408
  • 18:00
    typescript-bot closed #33449
  • 17:55
    RyanCavanaugh synchronize #15575
  • 17:55
    RyanCavanaugh synchronize #28460
  • 17:55
    RyanCavanaugh synchronize #31641
  • 17:55
    RyanCavanaugh milestoned #33483
  • 17:54
    RyanCavanaugh labeled #33483
  • 17:54

    RyanCavanaugh on master

    Narrow unknown under inequality… (compare)

  • 17:54
    RyanCavanaugh closed #33488
  • 17:54
    RyanCavanaugh closed #33483
  • 17:42
    AnyhowStep synchronize #33496
  • 17:36
    AnyhowStep opened #33496
  • 17:25
    RyanCavanaugh labeled #33493
  • 17:21
    jack-williams opened #33495
  • 17:06
    RyanCavanaugh labeled #33484
  • 17:03
    RyanCavanaugh edited #33484
  • 16:59
    RyanCavanaugh labeled #33491
  • 16:56
    RyanCavanaugh closed #33494
  • 16:56
    RyanCavanaugh labeled #33494
  • 16:56
    nkch8054 edited #33494
AnyhowStep
@AnyhowStep
It's interesting because this means we'll have two type guards that act on a nominal type but one does a structural narrowing (incorrectly, since structural assignment is allowed), while one does a nominal narrowing (correctly)
So, the rationale for keeping the instanceof behavior can no longer be "intentional for usability" but, rather, "for backwards compatibility"
AnyhowStep
@AnyhowStep
image.png
Dafuq is this ^M thing
Keith Layne
@keithlayne
windows line ending
AnyhowStep
@AnyhowStep
Ah.
TS code base uses those, I guess
Kudzu
@czhower
^M is #13 - ie CR
Bruce Pascoe
@fatcerberus
Yeah it’s half of a CRLF pair
Kudzu
@czhower
^ is old notation for control key.. ctrl + letter = low ASCII. M being 13th letter, ctrl-M is 13.

not all systems use #13#10... many use just #13. @keithlayne Its not windows.. windows is CR+LF...

I always code my code to accept CR, LF or CR+LF as all 3 are in use.

typically Windows is CRLF while *nix is LF.
Bruce Pascoe
@fatcerberus
It could still be windows. GitHub may be hardcoded to only look for LF so it just shows the CR as part of the line
*git, not github
I think CR by itself was strictly a mac thing (pre-OS X)
Kudzu
@czhower
yes, CR only was Mac. EAch one can do whatever as its not even part of the OS, but its general convention of programs that run on each ofthose.
CR alone isnt common... its usually CRLF or LF and generally CRLF is the most common today.
Keith Layne
@keithlayne
@czhower that's how CRLF shows up on i.e. linux a lot of times.
lipspotatochipss
@lipspotatochipss

How to use web workers in Typescript without using webpack?

I am new to Typescript and especially web worker. I found ways to make use of web worker in a typescript using web pack. But I am restrained with not using web pack. I was wondering is there a way to achieve it without the use of web pack.

I have tried doing it without web pack and I am able to reach my worker javascript file(It was a typescript file which compiled to a javascript). It throws me error "Uncaught ReferenceError: define is not defined". For this I changed the worker file and created a new javascript file which calls my previous worker file which does the actual task. I also included "webworker" in the tsconfig file but it then generates error at all places which overlaps with the dom. For eg., onmessage is present in both the libraries.

newfile.js

define(["require", "exports", "kloCommon/Schema/Schemas"], function (require, exports, Schemas) {
importScripts("Schemas.js");
onmessage = Schemas.onmessage;

});
Even this define throws me the same error. I know the 'define' is defined under RequireJs. Is there a way to import RequireJs before I need to use define?

I am sorry, I might be wrong at many levels and I might be also talking like a noob(which I am), so I am trying to get help for this sole reason. Thank you!

Bruce Pascoe
@fatcerberus
define is AMD modules
Kudzu
@czhower
Web pack is a bundler no? You seem to describe it as a library.
Bruce Pascoe
@fatcerberus
You might want to set module: none in tsconfig (and don’t use import in worker files)
Kudzu
@czhower
you dont need webpack to load other libraries. There a variety of ways to load libararies.
lipspotatochipss
@lipspotatochipss
@czhower like?
I tried setting lib to ["webworker", "dom"]
these two are getting me into trouble.
Kudzu
@czhower

Im not sure what you are trying to do - are you trying to load a library for web worker support? A d.ts?

You can easily create web workers without any special library.

lipspotatochipss
@lipspotatochipss
Its a web app. So I need dom to run my general files.
And now both(lib.dom.d.ts, lib.webworker.d.ts) together have "onmessage" and "postmessage" in them having different types.
Kudzu
@czhower
ok d.ts... thats different. d.ts arent libaries... you dont need to "load" them. d.ts files are just shape definitions for TS. you just include them when you compile with TSC, they dont get loaded at run time. And they arent even necessary although they are a good idea to use.
Kudzu
@czhower
ie, thus in most cases webpack doesnt deal with d.ts files or need to. They are only included when you call TSC.
lipspotatochipss
@lipspotatochipss

@czhower Thank you for replying to a noob like me :)
Right now I am able to make a web worker. Go into the worker.js . But my actual worker has been written in Typescript. So here I try to call my Typsecript( which is actually the .js file which creates during compilation; lets call this class xyz).
Now it is even going to xyz. But its the xyz.js file complied from xyz.ts file. I had few other classes imported into my xyz.ts file
which converts to xyz.ts as

define(["require", "exports", "kloCommon/Schema/Schemas"], function (require, exports, Schemas)

This is throwing me error "Uncaught ReferenceError: define is not defined".

Kudzu
@czhower

" other classes imported"

TS supports multiple ways to import because the JS world doesnt have just one standard load mechanism. So depending on what you specify for TSC as an option, it will generate different loading code which depends on you also having the loader loaded for support.

image.png
lipspotatochipss
@lipspotatochipss
thank you
Kudzu
@czhower
each of these are different loading systems and create different scaffolding.
image.png
Bruce Pascoe
@fatcerberus
Well it does have a standard mechanism now (ESM) but the rest of the ecosystem hasn’t quite caught up yet :smile:
Kudzu
@czhower
import/require and export are the TS key words that are affected by this option.
Parviz
@spyinfo
What types of question can i ask you all? :)
Kudzu
@czhower
@fatcerberus In time... ESM is "standard" as per spec, but not "standard" as per use yet as you say....
@lipspotatochipss Im happy to help noobs who know that they are noobs... and often its better to assist noobs as often many of the "non noobs" are "know it alls" and one has to often fight them to get them to understand things.
lipspotatochipss
@lipspotatochipss
Sir, I'm not sure if I have this in the config file. It's a task given to me at office. So I'll have to check and get back to you tomorrow. Also I'm using my friend's laptop with his id. So I'll be back tomorrow with a different profile. Thank you so much!
I'm from India so my office got over 4 hours back.
Thank you! :)
raghanag
@raghanag
Hi All, if my typescript classes uses requirejs libraries and my unit-tests uses commonjs style. how to make ts-mocha to run the unit tests without any errors. Now getting the below error.
import ExampleComponentModel = require('../../ts/jet-composites/my-cca/my-cca-viewModel');
                                                              ^
ReferenceError: define is not defined
and heres the command
    "test:unit": "ts-mocha -p src/test/tsconfig.json src/test/my-cca/**.ts"
is there something wring with my tsconfig,
{
    "compileOnSave": true,
    "compilerOptions": {
        "allowJs": true,
        "alwaysStrict": false,
        "baseUrl": ".",
        "checkJs": false,
        "lib": [
            "dom",
            "es5",
            "scripthost",
            "es2015.core",
            "es2015.collection",
            "es2015",
            "esnext.asynciterable"
        ],
        "module": "amd",
        "moduleResolution": "node",
        "noEmitOnError": true,
        "noImplicitAny": true,
        "noImplicitThis": true,
        "paths": {
            "knockout": [
                "../../node_modules/@types/knockout"
            ],
            "ojs/*": [
                "../../node_modules/@oracle/oraclejet/dist/types/*"
            ]
        },
        "rootDir": ".",
        "sourceMap": true,
        "strictFunctionTypes": true,
        "strictNullChecks": true,
        "target": "es2017",
        "typeRoots": [
            "../../node_modules/@types/"
        ]
    },
    "include": [
        "**/*"
    ]
}